package org.moonlight.jvm.classfile.constant.info.number;

import lombok.Getter;
import org.moonlight.jvm.classfile.ClassReader;
import org.moonlight.jvm.classfile.constant.ConstantInfo;

/**
 * CONSTANT_Integer_info使用4字节存储整数常量，其结构定义如下：
 *  CONSTANT_Integer_info {
 *      u1 tag
 *      u4 bytes
 *  }
 *
 *  {@link ConstantInfo#CONSTANT_INTEGER}
 *
 * @author Moonlight
 * @createTime 2023/8/15 11:03
 **/
@Getter
public class ConstantIntegerInfo implements ConstantInfo {

    private int val;

    @Override
    public void readInfo(ClassReader reader) {
        this.val = reader.readUint32ToInteger();
    }

    @Override
    public int tag() {
        return ConstantInfo.CONSTANT_INTEGER;
    }
}
